package com.hrzyit.whistle.cases.widgets

import android.content.Context
import android.util.Log
import android.view.View
import android.widget.AdapterView
import android.widget.SimpleAdapter
import android.widget.Toast
import com.hrzyit.base.ext.onClick
import com.hrzyit.whistle.cases.R
import com.hrzyit.whistle.cases.data.bean.CaseInfoEntity
import com.hrzyit.whistle.cases.data.bean.CaseSignInVo
import com.hrzyit.whistle.cases.data.bean.TransferCaseToDeptVo
import com.hrzyit.whistle.cases.presenter.CaseInfoPresenter
import com.hrzyit.whistle.cases.presenter.TransferSelectUserPresenter
import com.hrzyit.whistle.cases.ui.adapter.RejectReasonAdapter
import com.lxj.xpopup.animator.PopupAnimator
import com.lxj.xpopup.core.CenterPopupView
import kotlinx.android.synthetic.main.popup_case_accept.view.*
import kotlinx.android.synthetic.main.popup_case_accept.view.mCancelBtn
import kotlinx.android.synthetic.main.popup_case_accept.view.mConfirmBtn
import kotlinx.android.synthetic.main.popup_case_transfer_confirm.view.*
import org.jetbrains.anko.toast

/**
 * 弹出窗口：案件批转确认界面
 * @author YangWei
 * @date 2019/4/21
 */
class CaseTransferConfirmPopup (context: Context, val presenter: TransferSelectUserPresenter): CenterPopupView(context) {

    lateinit var transferCaseToDeptVo: TransferCaseToDeptVo

    // 返回自定义弹窗的布局
    override fun getImplLayoutId(): Int {
        return R.layout.popup_case_transfer_confirm
    }

    // 执行初始化操作，比如：findView，设置点击，或者任何你弹窗内的业务逻辑
    override fun onCreate() {
        super.onCreate()

        mReceiverUserNamesTv.text = transferCaseToDeptVo.userName
        mReceiverDeptNamesTv.text = transferCaseToDeptVo.deptName

        mConfirmBtn.onClick{

            // 批转说明
            mCaseTransferContextEt.text?.let {
                transferCaseToDeptVo.reason = it.toString()
            }
            presenter.saveTransferCaseToDept(transferCaseToDeptVo)
        }
        mCancelBtn.onClick{
            dismiss() // 关闭弹窗
        }
    }

    // 设置最大宽度，看需要而定
    override fun getMaxWidth(): Int {
        return super.getMaxWidth()
    }

    // 设置最大高度，看需要而定
    override fun getMaxHeight(): Int {
        return super.getMaxHeight()
    }

    // 设置自定义动画器，看需要而定
    override fun getPopupAnimator(): PopupAnimator {
        return super.getPopupAnimator()
    }
}